{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def loadDataSet():\n",
    "    dataMat = []\n",
    "    labelMat = []\n",
    "    fr = open('testSet.txt')\n",
    "    for line in fr.readlines():\n",
    "        lineArr = line.strip().split()\n",
    "        dataMat.append([1.0,float(lineArr[0]),float(lineArr[1])])\n",
    "        labelMat.append(int(lineArr[2]))\n",
    "    return dataMat , labelMat "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def sigmoid(inX):\n",
    "    return 1.0 / (1 + np.exp(-inX))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def gradAsecnt(dataMatIn,classLabels):\n",
    "    dataMatrix = np.array(dataMatIn)\n",
    "    labelMat = np.matrix(classLabels).transpose()\n",
    "    m , n = dataMatrix.shape\n",
    "    alpha = 0.01\n",
    "    maxCycles = 500\n",
    "    weights = np.ones((n,1))\n",
    "    for k in range(maxCycles):\n",
    "        h = sigmoid(np.dot(dataMatrix,weights))\n",
    "        error = (labelMat - h)\n",
    "        a =  np.dot(dataMatrix.T,error)\n",
    "        weights = weights + alpha *a \n",
    "    return weights"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "dataArr , labelMat = loadDataSet()\n",
    "weights = gradAsecnt(dataArr , labelMat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((3, 1), (100, 3))"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weights.shape,np.array(dataArr).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def plotBestFit(wei):\n",
    "    weights = np.array(wei)\n",
    "    dataMat,labelMat = loadDataSet()\n",
    "    dataArr  = np.array(dataMat)\n",
    "    n = dataArr.shape[0]\n",
    "    xcord1 = []\n",
    "    ycord1 = []\n",
    "    xcord2 = []\n",
    "    ycord2 = []\n",
    "    for i in range(n):\n",
    "        if int(labelMat[i]) == 1:\n",
    "            xcord1.append(dataArr[i,1])\n",
    "            ycord1.append(dataArr[i,2])\n",
    "        else:\n",
    "            xcord2.append(dataArr[i,1])\n",
    "            ycord2.append(dataArr[i,2])\n",
    "    fig = plt.figure()\n",
    "    ax = fig.add_subplot(111)\n",
    "    ax.scatter(xcord1 , ycord1 ,s=30,c='red',marker='s')\n",
    "    ax.scatter(xcord2 , ycord2 ,s=30,c='green')\n",
    "    x = np.array([-3.0,3.0,0.1])\n",
    "    y = (-weights[0] - weights[1]*x ) / weights[2]\n",
    "    ax.plot(x,y)\n",
    "    plt.xlabel('x1')\n",
    "    plt.ylabel('x2')\n",
    "    plt.show()\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X2QVPW95/H3FwYEZgafZkCFQQS5Kj5g4mS4N5qs2YgB\nbjYmtblbumty87ABUgnJrdosa5LKw002dzdkNzd3NTeoq5UnkuytSjSWFxMhSZWJ0REwIAqaAD4M\niDCKPBthmO/+0d1j09Pd02emT5/fOfN5VU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u\nQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x18f61edb8d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plotBestFit(weights)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def stocGradAscent0(dataMatrix,classLabels):\n",
    "    m,n = dataMatrix.shape\n",
    "    alpha = 0.01\n",
    "    weights = np.ones(n)\n",
    "    for i in range(m):\n",
    "        h = sigmoid(np.sum(np.dot(dataMatrix[i] ,weights )))\n",
    "        error = classLabels[i] - h\n",
    "        weights = weights + alpha* error * dataMatrix[i]\n",
    "    return np.array(weights)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XeYVPXZ//H3vVTpSpOyKypNVEBclygidoEYSzRGo8aW\nIHksMYkSk/zS4/Uo9o5YYqLYkqjxMQiKJShKVcACSxNcOoj0tuX+/bHDsixbZnZn5pwz+3ld117s\n+c6ZmXt2hu8951vN3REREYlXVtABiIhItChxiIhIQpQ4REQkIUocIiKSECUOERFJiBKHiIgkRIlD\nREQSosQhIiIJUeIQEZGENAw6gFRo166dd+vWLegwREQiY9asWevdvX0852Zk4ujWrRszZ84MOgwR\nkcgws2XxnqumKhERSYgSh4iIJESJQ0REEqLEISIiCUl54jCzp8xsrZl9Vq7sD2a2wsxmx36GV3Hf\noWaWb2aLzOzWVMcqIiI1S8cVx9PA0ErK73X3/rGf8RVvNLMGwMPAMKAPcImZ9UlppCIiUqOUJw53\nnwxsqMVd84BF7r7E3XcDLwDnJjU4ERFJWJB9HDeY2dxYU9aBldzeBSgod7w8VlYpMxthZjPNbOa6\ndeuSHatI5B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IhIQv4/\n7rejemIqxvoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x18f63fd1e48>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "weights = stocGradAscent0(np.array(dataArr) , labelMat)\n",
    "\n",
    "plotBestFit(weights)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def stocGradAscent1(dataMatrix,classLabels , numIter = 150):\n",
    "    m,n = dataMatrix.shape\n",
    "    weights = np.ones(n)\n",
    "    for j in range(numIter):\n",
    "        dataIndex = list(range(m))\n",
    "        for i in range(m):\n",
    "            alpha = 4 / (1.0 + j + i) + 0.01\n",
    "            randIndex = int(np.random.uniform(0 , len(dataIndex)))\n",
    "            h = sigmoid(np.sum(np.dot(dataMatrix[randIndex] ,weights )))\n",
    "            error = classLabels[randIndex] - h\n",
    "            weights = weights + alpha* error * dataMatrix[randIndex]\n",
    "    return np.array(weights)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtwXOWZ5/HvI8lXScYXtQ22JWyBg+0QDEGRUwEyEAxr\nHCYku5ldmCXZXDaGVGAyVZvy5LJJZpJN1cbZnc0uJDHOhsqNkJ2qBEIlTohNMsMlQdhmDAbbgC8E\nIUCWcSzfL5Ke/aNbtix1t/pIffpc9PtUqdR9+nTrabV0nvO+7/O+x9wdERGRUlVFHYCIiCSLEoeI\niASixCEiIoEocYiISCBKHCIiEogSh4iIBKLEISIigShxiIhIIEocIiISSE3UAYShoaHB582bF3UY\nIiKJsXnz5n3unill31Qmjnnz5rFp06aowxARSQwz+1Op+6qrSkREAlHiEBGRQJ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HCIiEogSh4iIBKLE\nISIigShxiIhIIEocIhVkZr8xswNm9suoYxEZKSUOkcr6BvChqIMQGQ0lDpEQmNk7ctcomWhmtbnr\nJFzs7o8Ah6KOT2Q0tFaVSAjcfaOZPQT8N2AS8GN3T8xFjUSKUeIQCc9XyK41dRz4m4hjESkbdVWJ\nhGcGUAfUAxMjjkWkbJQ4RMJzD/BFssvkfz3iWETKRl1VIiEwsw8Dp9z9J7nrhv/BzN4D/AOwEKgz\ns1eBj7v7w1HGKhKUVscVEZFA1FUlIiKBKHGIiEggShwiIhKIEoeIiASixCEiIoEocYiISCBKHCIi\nEogSh4iIBPL/AadI4S0xVPOXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x18f61f56668>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "weights = stocGradAscent1(np.array(dataArr) , labelMat ,200)\n",
    "\n",
    "plotBestFit(weights)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def classifyVector(inX,weights):\n",
    "    prob = sigmoid(np.sum(inX * weights))\n",
    "    if prob > 0.5:\n",
    "        return 1.0\n",
    "    else:\n",
    "        return 0.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def colicTest():\n",
    "    frTrain = open('horseColicTraining.txt'); frTest = open('horseColicTest.txt')\n",
    "    trainingSet = []; trainingLabels = []\n",
    "    for line in frTrain.readlines():\n",
    "        currLine = line.strip().split('\\t')\n",
    "        lineArr =[]\n",
    "        for i in range(21):\n",
    "            lineArr.append(float(currLine[i]))\n",
    "        trainingSet.append(lineArr)\n",
    "        trainingLabels.append(float(currLine[21]))\n",
    "    trainWeights = stocGradAscent1(np.array(trainingSet), trainingLabels, 1000)\n",
    "    errorCount = 0; numTestVec = 0.0\n",
    "    for line in frTest.readlines():\n",
    "        numTestVec += 1.0\n",
    "        currLine = line.strip().split('\\t')\n",
    "        lineArr =[]\n",
    "        for i in range(21):\n",
    "            lineArr.append(float(currLine[i]))\n",
    "        if int(classifyVector(np.array(lineArr), trainWeights))!= int(currLine[21]):\n",
    "            errorCount += 1\n",
    "    errorRate = (float(errorCount)/numTestVec)\n",
    "    print (\"the error rate of this test is: %f\" % errorRate)\n",
    "    return errorRate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def multiTest():\n",
    "    numTests = 10; errorSum=0.0\n",
    "    for k in range(numTests):\n",
    "        errorSum += colicTest()\n",
    "    print (\"after %d iterations the average error rate is: %f\" % (numTests, errorSum/float(numTests)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\RUANJIAN\\Anaconda3\\Anaconda3_3\\lib\\site-packages\\ipykernel\\__main__.py:2: RuntimeWarning: overflow encountered in exp\n",
      "  from ipykernel import kernelapp as app\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the error rate of this test is: 0.268657\n",
      "the error rate of this test is: 0.447761\n",
      "the error rate of this test is: 0.253731\n",
      "the error rate of this test is: 0.298507\n",
      "the error rate of this test is: 0.358209\n",
      "the error rate of this test is: 0.253731\n",
      "the error rate of this test is: 0.238806\n",
      "the error rate of this test is: 0.268657\n",
      "the error rate of this test is: 0.253731\n",
      "the error rate of this test is: 0.328358\n",
      "after 10 iterations the average error rate is: 0.297015\n"
     ]
    }
   ],
   "source": [
    "multiTest()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
